package com.lagou.client;

import com.lagou.service.UserService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * @author Mrwg
 * @date 2020/5/23
 * @description
 */
@Component
public class ClientStarter implements ApplicationRunner {
    public static final String providerName = "UserService#sayHello#";
    @Override
    public void run(ApplicationArguments args) throws Exception {
        RpcConsumer rpcConsumer = new RpcConsumer();
        UserService proxy = (UserService) rpcConsumer.createProxy(UserService.class,providerName);
        while (true) {
            Thread.sleep(2000);
            System.out.println(proxy.sayHello("Hello!"));
        }
    }
}
